/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 */

import React from "react";
import Login from "./Page/Login";
import { NavigationContainer, StackRouter } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import Main from "./Page/Main";
import RNMMKV from "./Native/Module/RNMMKV.ts";
import Setting from "./Page/Main/UserCenter/Setting";
import { Provider } from "react-redux";
import store from "./src/store/store.ts";

const Stack = createNativeStackNavigator();

function App(): React.JSX.Element {

  const startPage = (): string => {
    const isLogin = RNMMKV.getBoolean("is_login");
    return isLogin ? "Main" : "Login";
  };

  return (
    <Provider store={store}>
      <NavigationContainer>
        <Stack.Navigator initialRouteName={startPage()}>
          <Stack.Screen name="Login" component={Login} />
          <Stack.Screen name="Main" component={Main} options={{ headerShown: false }} />
          <Stack.Screen name="Setting" component={Setting} />
        </Stack.Navigator>
      </NavigationContainer>
    </Provider>
  );
}

export default App;
